package org.example.coffeeshoporderingsystem.login.controller;

import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import org.example.coffeeshoporderingsystem.common.ui.UIManager;
import org.example.coffeeshoporderingsystem.common.util.SpringContextUtil;
import org.example.coffeeshoporderingsystem.staff.service.StaffService;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

public class LoginController{
    public TextField accountTxf;
    public TextField pswdTxf;
    private StaffService staffService = SpringContextUtil.getBean(StaffService.class);
    public void login() throws IOException {
        // 登录
        if (staffService.login(accountTxf.getText(), pswdTxf.getText())) {
            UIManager.switchToMain();
        } else {
            UIManager.showAlertError("账号或密码错误");
        }
    }
}